package org.lsy.filter;

import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.rpc.*;

/**
 * @author liusy95
 * @version 1.0
 * @date 2020/6/30
 */
@Activate(group = {CommonConstants.CONSUMER})
public class TransportIpFilter implements Filter {

    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        RpcContext.getContext().setAttachment("ip", NetUtils.getLocalHost());
        return invoker.invoke(invocation);
    }
}
